<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <ul id="list">
      <li>
        li1
        <ul>
          <li>l11</li>
          <li>l12</li>
          <li>
            l13
            <ul>
              <li>l131</li>
              <li>l132</li>
            </ul>
          </li>
        </ul>
      </li>
      <li>
        li2
        <ul>
          <li>l21</li>
          <li>l22</li>
          <li>l23</li>
          <li>l24</li>
        </ul>
      </li>
      <li>li3</li>
    </ul>
    <script>
      /*
      ul->[①li]->[②ul]->[③li]
      1. 遍历出所有li标签对象
      2. 遍历出所有li标签对象中ul，排除没ul的情况
      */
      const list = document.getElementById("list");
      // console.log(list.children);
      // ul->[①li]
      [...list.children].forEach((el) => {
        // ul->[①li]->[②ul]
        if (el.children.length !== 0) {
          // ul->[①li]->[②ul]->[③li]
          console.log(el.children[0].children);
        }
      });
    </script>
  </body>
</html>
